public class Solution {
    public int MinimumCardPickup(int[] cards) {
        Dictionary<int,int> dic = new Dictionary<int,int>();
        int ans = 100010;
        bool flag = false;
        for(int i = 0;i<cards.Length;i++){
            if(dic.ContainsKey(cards[i])){
                flag = true;
                ans = Math.Min(ans,i + 1 - dic[cards[i]] + 1);
            }
            dic[cards[i]] = i + 1;
        }return flag ? ans:-1;
    }
}